﻿using System;
using System.Collections.Generic;
using System.Text;
using reactiveBT.Utilities;

namespace reactiveBT.BT
{
    /// <summary>
    /// 条件叶节点，接受一个无参，返回值为bool的函数func作为构造参数
    /// 根据函数func的执行结果返回Success或Failure
    /// 测试通过
    /// </summary>
    public class Condition : BTNode
    {
        System.Func<int, bool> fn;
        public Condition(System.Func<int, bool> fn)
        {
            this.fn = fn;
        }
        public override BTState Tick(int BTid)
        {
            return fn(BTid) ? BTState.Success : BTState.Failure;
        }
    }
}
